﻿<UserControl x:Class="ModernUILogViewer.Content.ContentStatisticsInterval"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"
             xmlns:chartingprimitive="clr-namespace:System.Windows.Controls.DataVisualization.Charting.Primitives;assembly=System.Windows.Controls.DataVisualization.Toolkit"
             xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
             xmlns:datavis="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"             
             xmlns:model="clr-namespace:ModernUILogViewer.Model"
             xmlns:business="clr-namespace:ModernUILogViewer.Business"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"                
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"                             
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">

    <UserControl.Resources>
        
        <business:DataContextSpy x:Key="spy" />
        
        <!-- not used -->
        
        <!--<ObjectDataProvider x:Key="levels" 
                        MethodName="GetNames" ObjectType="{x:Type sys:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="model:LOG_LEVEL" />
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>-->
        

        <datavis:ResourceDictionaryCollection x:Key="userPalette">
            <ResourceDictionary>
                <Style x:Key="DataPointStyle" TargetType="Control" >
                    <Setter Property="Background" Value="{Binding Source={StaticResource colorsettings}, Path=NoneColor, TargetNullValue={StaticResource NONE_COLOR}}"/>
                </Style>
            </ResourceDictionary>

            <ResourceDictionary>
                <Style x:Key="DataPointStyle" TargetType="Control" >
                    <Setter Property="Background" Value="{Binding Source={StaticResource colorsettings}, Path=DebugColor, TargetNullValue={StaticResource DEBUG_COLOR}}" />
                </Style>
            </ResourceDictionary>

            <ResourceDictionary>
                <Style x:Key="DataPointStyle" TargetType="Control" >
                    <Setter Property="Background" Value="{Binding Source={StaticResource colorsettings}, Path=InfoColor, TargetNullValue={StaticResource INFO_COLOR}}" />
                </Style>
            </ResourceDictionary>

            <ResourceDictionary>
                <Style x:Key="DataPointStyle" TargetType="Control" >
                    <Setter Property="Background" Value="{Binding Source={StaticResource colorsettings}, Path=WarnColor, TargetNullValue={StaticResource WARN_COLOR}}" />
                </Style>
            </ResourceDictionary>

            <ResourceDictionary>
                <Style x:Key="DataPointStyle" TargetType="Control" >
                    <Setter Property="Background" Value="{Binding Source={StaticResource colorsettings}, Path=ErrorColor, TargetNullValue={StaticResource ERROR_COLOR}}" />
                </Style>
            </ResourceDictionary>

            <ResourceDictionary>
                <Style x:Key="DataPointStyle" TargetType="Control" >
                    <Setter Property="Background" Value="{Binding Source={StaticResource colorsettings}, Path=FatalColor, TargetNullValue={StaticResource FATAL_COLOR}}" />
                </Style>
            </ResourceDictionary>
        </datavis:ResourceDictionaryCollection>

        <Style x:Key="legendStyle1" TargetType="datavis:Legend">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Control.BorderBrush" Value="{DynamicResource ButtonBorder}" />
            <Setter Property="Control.Background" Value="Transparent" />
            <!--<Setter Property="Width" Value="0"></Setter>
            <Setter Property="Height" Value="0"></Setter>-->
            <Setter Property="Visibility" Value="Hidden"></Setter>
            <Setter Property="BorderThickness" Value="0" />
        </Style>

        <Style TargetType="{x:Type charting:Chart}">
            <Setter Property="PlotAreaStyle">
                <Setter.Value>
                    <Style TargetType="{x:Type Grid}">
                        <Setter Property="Background" Value="Transparent"/>
                    </Style>
                </Setter.Value>
            </Setter>
        </Style>

        <ControlTemplate x:Key="template1" TargetType="charting:Chart">
            <Border Background="{TemplateBinding Control.Background}"
                    BorderBrush="{DynamicResource ButtonBorder}"
                    BorderThickness="{TemplateBinding Control.BorderThickness}"
                    Padding="{TemplateBinding Control.Padding}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <datavis:Title Content="{TemplateBinding charting:Chart.Title}" Style="{TemplateBinding charting:Chart.TitleStyle}" />
                    <Grid Grid.Row="1" Margin="0,15">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <datavis:Legend Name="Legend"
                                                     Title="{TemplateBinding charting:Chart.LegendTitle}"
                                                     Grid.Column="1"
                                                     Style="{TemplateBinding charting:Chart.LegendStyle}" />
                        <chartingprimitive:EdgePanel Name="ChartArea" Style="{TemplateBinding charting:Chart.ChartAreaStyle}">
                            <Grid Panel.ZIndex="-1" Style="{TemplateBinding charting:Chart.PlotAreaStyle}" />
                            <!--<Border Panel.ZIndex="10"
                                    BorderBrush="#FF919191"
                                    BorderThickness="1" />-->

                        </chartingprimitive:EdgePanel>
                    </Grid>
                </Grid>
            </Border>
        </ControlTemplate>

    </UserControl.Resources>

    <ScrollViewer>
        <Grid>
            <DockPanel>
                <!--<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Margin="{StaticResource DefaultMargin}">
                    <TextBlock VerticalAlignment="Center" Style="{StaticResource Heading2}" Margin="{StaticResource DefaultLeftMargin}">LEVEL</TextBlock>
                    <ComboBox 
                        Margin="{StaticResource DefaultLeftMargin}"
                        x:Name="cmbLevels"                        
                        Width="200"                    
                        SelectedItem="{Binding SelectedLevel, Mode=OneWayToSource}"
                        ItemsSource="{Binding Source={StaticResource levels}}"                       
                      />
                </StackPanel>-->
                <charting:Chart 
                    Template="{StaticResource template1}"
                    LegendStyle="{StaticResource legendStyle1}"
                    Palette="{StaticResource userPalette}"
                    Title="DAY STATISTICS"                    
                    TitleStyle="{StaticResource TitleStyle2}"
                    >
                    <charting:ColumnSeries       
                         AnimationSequence="Simultaneous"
                         FlowDirection="LeftToRight"
                         Title="NONE"
                         DependentValueBinding="{Binding Value}"
                         IndependentValueBinding="{Binding Key}"
                         ItemsSource="{Binding DateEntriesKV[0]}"
                         LegendItemStyle="{StaticResource LegendItemStyle2}"
                    />
                    <charting:ColumnSeries       
                         AnimationSequence="Simultaneous"
                         FlowDirection="LeftToRight"       
                         Title="DEBUG"
                         DependentValueBinding="{Binding Value}"
                         IndependentValueBinding="{Binding Key}"
                         ItemsSource="{Binding DateEntriesKV[1]}"
                         LegendItemStyle="{StaticResource LegendItemStyle2}"
                    />
                    <charting:ColumnSeries       
                         AnimationSequence="Simultaneous"
                         FlowDirection="LeftToRight"       
                         Title="INFO"
                         DependentValueBinding="{Binding Value}"
                         IndependentValueBinding="{Binding Key}"
                         ItemsSource="{Binding DateEntriesKV[2]}"
                         LegendItemStyle="{StaticResource LegendItemStyle2}"
                    />
                    <charting:ColumnSeries       
                         AnimationSequence="Simultaneous"
                         FlowDirection="LeftToRight"       
                         Title="WARN"
                         DependentValueBinding="{Binding Value}"
                         IndependentValueBinding="{Binding Key}"
                         ItemsSource="{Binding DateEntriesKV[3]}"
                         LegendItemStyle="{StaticResource LegendItemStyle2}"
                    />
                    <charting:ColumnSeries       
                         AnimationSequence="Simultaneous"
                         FlowDirection="LeftToRight"       
                         Title="ERROR"
                         DependentValueBinding="{Binding Value}"
                         IndependentValueBinding="{Binding Key}"
                         ItemsSource="{Binding DateEntriesKV[4]}"
                         LegendItemStyle="{StaticResource LegendItemStyle2}"
                    />
                    <charting:ColumnSeries       
                         LegendItemStyle="{StaticResource LegendItemStyle2}"
                         AnimationSequence="Simultaneous"
                         FlowDirection="LeftToRight"       
                         Title="FATAL"
                         DependentValueBinding="{Binding Value}"
                         IndependentValueBinding="{Binding Key}"
                         ItemsSource="{Binding DateEntriesKV[5]}"
                     
                    />
                </charting:Chart>
            </DockPanel>
        </Grid>
    </ScrollViewer>

    <!--<i:Interaction.Triggers>

        <i:EventTrigger EventName="SelectionChanged" SourceName="cmbLevels">
            <i:InvokeCommandAction Command="{Binding UpdateIntervalStatisticsSubject}" />
        </i:EventTrigger>

    </i:Interaction.Triggers>-->

</UserControl>
